package com.onepiece.shipelves.common.enums;


import org.apache.commons.lang3.StringUtils;

/**
 * @author guoyanjiang
 * @date 2019-06-17
 */
public enum App {
    All("all"),
    BTC8("8btc"),
    CHAINNODE("chainnode"),
    QKL123("qkl123"),
    ;

    public String code;

    App(String code) {
        this.code = code;
    }

    public static String transToAppCode(String ua) {
        if (StringUtils.isEmpty(ua)) {
            return BTC8.code;
        }
        ua = ua.toLowerCase();
        if (ua.contains(BTC8.code)) {
            return BTC8.code;
        } else if (ua.contains(CHAINNODE.code)) {
            return CHAINNODE.code;
        } else if (ua.contains(QKL123.code)) {
            return QKL123.code;
        } else {
            return BTC8.code;
        }
    }
}
